import type { FieldRule } from "vant"

// 表单校验
const mobileRules = [
  { required: true, message: '请输入手机号' },
  { pattern: /^1[3-9]\d{9}$/, message: '手机号格式不正确' }
]

const passwordRules = [
  { required: true, message: '请输入密码' },
  { pattern: /^\w{8,24}$/, message: '密码需8-24个字符' }
]

const nameRules: FieldRule[] = [{
  required: true,
  message: '请填写真实姓名'
}]

const cardIdRules: FieldRule[] = [
  {
    required: true,
    message: '请填写身份证号码'
  },
  {
    pattern: /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,
    message: '请输入正确的身份证号码'
  }
]

export { mobileRules, passwordRules, nameRules, cardIdRules }
